home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / toolbox < prev    next >
Internet Message Format  |  1995-03-31  |  23KB

  1. From helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean Wed May 23 05:29:05 PDT 1990
  2. Status: RO
  3.  
  4. Article 1726 of comp.sys.handhelds:
  5. Path: helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean
  6. >From: jean@mcgill-vision.uucp (Pierre Racz)
  7. Newsgroups: comp.sys.handhelds
  8. Subject: An HP48 tool box
  9. Message-ID: <1990May23.013801.7712@larry.mcrcim.mcgill.edu>
  10. Date: 23 May 90 01:38:01 GMT
  11. Sender: root@larry.mcrcim.mcgill.edu (el Root)
  12. Reply-To: pierrer@pike.ee.mcgill.ca (Pierre Racz)
  13. Organization: Electrical Engineering McGill University
  14. Lines: 461
  15.  
  16. %%HP: T(3)A(R)F(.);
  17. @   Name      : TOOLS - Self extracting toolbox.
  18. @   Author    : Pierre Racz  &    Gregor Winslow
  19. @   Email     : pierrer <at> pike.ee.mcgill.ca
  20. @   Date      : 90-04-29
  21. @   Release   : 1.0
  22. @
  23. @   Checksum  : # 4494h
  24. @   Bytes     : 2,175.5
  25. @
  26. @   Descrip   :
  27. @        Self extracting list of functions.
  28. @        This program is designed to setup the HP48SX with global
  29. @        utilities, variables and directories.
  30. @
  31. @        Simply execute it in the directory of your choice (presumably
  32. @        the ROOT).
  33. @
  34. @        The following functions are extracted:
  35. @
  36. @        IOTA    Create a list of integers.
  37. @        LOP    Apply an operator to elements of a list.
  38. @        LPP    Apply an operator on elements of two lists in parallel.
  39. @        LRED    Reduce a list into a scalar given an operator.
  40. @        LRNG    Returns the Minimum and Maximum of a list.
  41. @        LINV    Invert a list
  42. @        LST\->    Shift a list right
  43. @        LST\<-    Shift a list left
  44. @        LCONVL    Produces a Linear Convolution of two lists.
  45. @        LOOP    Apply an operator n times.
  46. @        FROMTO    Generate n+1 numbers in given range.
  47. @        GCD    Greatest Common Divisor
  48. @        LCM    Least Common Multiple
  49. @        POLY    Create a polynomial algebraic form list of coefficients.
  50. @        BINO    Create a binomial algebraic form list of roots.
  51. @        SYND    Synthetic division of two polynomials.
  52. @        EXCO    Fully expand then fully collect.
  53. @        REVAL    Fully evaluate.
  54. @
  55. @        The following empty directories are created:
  56. @
  57. @        EE    Engineering applications
  58. @        ETC    Miscellaneous applications
  59. @        ECON    Time Value of Money
  60. @        HELP    General information storage
  61. @        STATS    Stat functions
  62. @        TMP    Temp
  63. @
  64. @        The following (dummy) variables are created.  They are
  65. @        essentially place holders for variables that the system
  66. @        automatically creates.    This preemptive creation ensures that
  67. @        the system does not change the ordering of the root directory.
  68. @
  69. @        PRTPAR    Printer parameters.
  70. @        IOPAR    IO parameters.
  71. @
  72. @        They USER Keys are defined and so are the System flags.
  73. @        A comment has to be removed to enable this feature.
  74. @
  75. @   Usage     :
  76. @        1:            No parameters required.
  77. @        TOOLS
  78. @        1:            Returns Nothing
  79. @
  80. @---------------------------------------
  81. \<<
  82.     {
  83. @
  84. @   ---
  85. @   Create a Polynomial
  86. @
  87. @   2:    'X'                             Variable
  88. @   1:    { 1 2 -3 4 }            List of Polynomial coefficients.
  89. @   POLY
  90. @   1:    'X^3+2*X^2-3*X+4'               Polynomial
  91. @
  92.     'POLY'
  93.     \<< \-> v l
  94.       \<< l SIZE \-> n
  95.     \<< 0 n 1 - 0
  96.       FOR i
  97.         l n i - GET v i ^ * +
  98.       -1 STEP
  99.     \>>
  100.       \>>
  101.     \>>
  102. @
  103. @   ---
  104. @   Synthetic Polynomial Division
  105. @
  106. @   2:    { 2 11 17 6 }            2*X^3 + 11*X^2 + 17*X + 6
  107. @   1:    { 2 1 }             divided 2*X + 1
  108. @    SYND
  109. @   2:    { 0 }                Remainder : 0
  110. @   1:    { 1 5 6 }            Quotient  : X^2 + 5*X + 6
  111. @
  112.     'SYND'
  113.     \<< \-> A B
  114.       \<< A SIZE B SIZE DUP2 - 1 + OVER 1 -
  115.     \-> n m q r
  116.     \<< 1 n
  117.       FOR i
  118.         A i GET 2 i q - 1 + MAX m
  119.         FOR j
  120.           IF j i \<=
  121.           THEN j PICK B j GET * -
  122.           END
  123.         NEXT
  124.         IF i q \<=
  125.         THEN B 1 GET /
  126.         END
  127.       NEXT
  128.       r \->LIST q 1 + ROLLD q \->LIST
  129.     \>>
  130.       \>>
  131.     \>>
  132. @
  133. @   ---
  134. @   Create a Binomial
  135. @
  136. @   2:    'X'                             Variable
  137. @   1:    { 1 2 -3 }            List of roots.
  138. @   BINO
  139. @   1:    '(X-1)*(X-2)*(X+3)'             Binomial
  140. @
  141. @
  142.     'BINO'
  143.     \<< \-> v l
  144.       \<< 1 1 l SIZE
  145.     FOR i
  146.         v l i GET - *
  147.     NEXT
  148.       \>>
  149.     \>>
  150. @
  151. @   ---
  152. @   Expand and Collect Fully
  153. @
  154. @   1:    '(X-1)*(X-2)'
  155. @   EXCO
  156. @   1:    '2+X^2-3*X'
  157. @
  158.     'EXCO'
  159.     \<<
  160.       DO DUP EXPAN SWAP
  161.       UNTIL OVER SAME
  162.       END
  163.       DO DUP COLCT SWAP
  164.       UNTIL OVER SAME
  165.       END
  166.     \>>
  167. @
  168. @   ---
  169. @   Repeated Eval (until no change)
  170. @
  171.     'REVAL'
  172.     \<<
  173.       DO DUP EVAL SWAP
  174.       UNTIL OVER SAME
  175.       END
  176.     \>>
  177. @
  178. @   ---
  179. @   Greatest Common Divisor.
  180. @
  181.     'GCD'
  182.     \<<
  183.       WHILE DUP
  184.       REPEAT SWAP OVER MOD
  185.       END DROP
  186.     \>>
  187. @
  188. @   ---
  189. @   Least Common Multiple
  190. @
  191.     'LCM'
  192.     \<< \-> a b
  193.       \<< a b * a b GCD /
  194.       \>>
  195.     \>>
  196. @
  197. @   ---
  198. @   Create a list of numbers from 0 to N
  199. @
  200. @   1:    5                n
  201. @    IOTA
  202. @   1:    { 0 1 2 3 4 5 }         Generates n+1 elements.
  203. @
  204.     'IOTA'
  205.     \<< \-> n
  206.       \<< 0 n
  207.     FOR i i
  208.     NEXT
  209.     n 1 + \->LIST
  210.       \>>
  211.     \>>
  212. @
  213. @   ---
  214. @   Invert list.
  215. @
  216. @   1:    { 0 1 2 3 4 5 }
  217. @    LINV
  218. @   1:    { 5 4 3 2 1 0 }
  219. @
  220.     'LINV'
  221.     \<< \-> L
  222.       \<< L SIZE 1
  223.     FOR i
  224.       L i GET
  225.     -1 STEP
  226.     L SIZE \->LIST
  227.       \>>
  228.     \>>
  229. @
  230. @   ---
  231. @   Rotate a list Right
  232. @
  233. @   1:    { 0 1 2 3 4 5 }
  234. @    LST\->
  235. @   1:    { 5 0 1 2 3 4 }
  236. @
  237.     'LST\->'
  238.     \<< OBJ\-> \-> SZ
  239.       \<< SZ ROLLD SZ \->LIST
  240.       \>>
  241.     \>>
  242. @
  243. @
  244. @   ---
  245. @   Rotate a list Left
  246. @
  247. @   1:    { 0 1 2 3 4 5 }
  248. @    LST\<-
  249. @   1:    { 1 2 3 4 5 0 }
  250. @
  251.     'LST\<-'
  252.     \<< OBJ\-> \-> SZ
  253.       \<< SZ ROLL SZ \->LIST
  254.       \>>
  255.     \>>
  256. @
  257. @   ---
  258. @   List OP.
  259. @
  260. @   2:    { 0 1 2 3 4 5 }
  261. @   1:    \<< 1 + \>>            Increment each element of list.
  262. @    LOP
  263. @   1:    { 1 2 3 4 5 6 }
  264. @
  265.     'LOP'
  266.     \<< \-> l f
  267.       \<< 1 l SIZE
  268.     FOR i
  269.         l i GET f EVAL
  270.     NEXT l
  271.     SIZE \->LIST
  272.       \>>
  273.     \>>
  274. @
  275. @   ---
  276. @   List Parallel Process.
  277. @
  278. @   3:    { 0 1 2 3 4 5 }
  279. @   2:    { 5 4 3 2 1 0 }
  280. @   1:    \<< * \>>            Multiply corresponding elements.
  281. @    LPP
  282. @   1:    { 0 4 6 6 4 0 }
  283. @
  284.     'LPP'
  285.     \<< \-> A B f
  286.       \<< A SIZE B SIZE MIN
  287.     \-> m
  288.     \<< 1 m
  289.       FOR i
  290.         A i GET B i GET f EVAL
  291.       NEXT m \->LIST
  292.     \>>
  293.       \>>
  294.     \>>
  295. @
  296. @   ---
  297. @   List Reduce.
  298. @
  299. @   2:    { 0 1 2 3 4 5 }
  300. @   1:    \<< + \>>            Sum the elements of the list.
  301. @    LRED
  302. @   1:    15
  303. @
  304.     'LRED'
  305.     \<< \-> L f
  306.       \<< L 1 GET 2 L SIZE
  307.     FOR i
  308.         L i GET f EVAL
  309.     NEXT
  310.       \>>
  311.     \>>
  312. @
  313. @   ---
  314. @   List range
  315. @
  316. @   1:    { 3 4 -2 1 8 }
  317. @    LRNG
  318. @   2:    -2                Minimum element of list.
  319. @   1:    8                Maximum element of list.
  320. @
  321.     'LRNG'
  322.     \<< \-> L
  323.       \<< L 1 GET DUP 2 L SIZE
  324.     FOR i L i GET
  325.       \-> m n x            @ m=min n=max x=element under test.
  326.       \<< m  x MIN n  x MAX
  327.       \>>
  328.     NEXT
  329.       \>>
  330.     \>>
  331. @
  332. @   ---
  333. @   Linear Convolution (Multiply two polynomials)
  334. @
  335. @   2:    { 1 2 1 }            X^2+2*X+1
  336. @   1:    { 1 3 3 1 }            X^3+3*X^2+3*X+1
  337. @    LCONVL
  338. @   1:    { 1 5 10 10 5 1 }        X^5 + 5*X^4 + 10*X^3 + 10*X^2 + 5*X + 1
  339. @
  340.     'LCONVL'
  341.     \<< \-> H X
  342.       \<< X SIZE H SIZE OVER + 1 - \-> N1 N    @ N Size of X
  343.     \<< 1 N                 @ N Size of result
  344.       FOR n
  345.         0 1 N1
  346.         FOR k
  347.           H n k - 1 +
  348.           IFERR GET             @ Try and get element from list.
  349.           THEN DROP2            @ Out of bounds, It is zero.
  350.           ELSE X k GET * +
  351.           END
  352.         NEXT
  353.       NEXT N \->LIST
  354.     \>>
  355.       \>>
  356.     \>>
  357. @
  358. @   ---
  359. @   Executes operation N times.
  360. @
  361. @   4:    { 1 1 }
  362. @   3:    { 1 1 }             Raise this poly to the 4th power.
  363. @   2:    \<< OVER LCONVL \>>
  364. @   1:    4
  365. @    LOOP
  366. @   2:    { 1 1 }
  367. @   1:    { 1 5 10 10 5 1 }
  368. @
  369.     'LOOP'
  370.     \<< \-> f n
  371.       \<<
  372.     WHILE 'n' DECR 0 \>=
  373.     REPEAT f EVAL
  374.     END
  375.       \>>
  376.     \>>
  377. @
  378. @   ---
  379. @   Creates List of n+1 elements from a to b.
  380. @
  381. @   3:    5                Want 5+1 elements
  382. @   2:    1                From 1
  383. @   1:    2                To   2
  384. @    FROMTO
  385. @   1:    { 1  1.2  1.4  1.6  1.8  2 }
  386. @
  387.     'FROMTO'
  388.     \<< \-> n a b
  389.       \<< n IOTA
  390.     \<< b a - n / * a +
  391.     \>> LOP
  392.       \>>
  393.     \>>
  394. @
  395.     }    @   End list of tools.
  396. @
  397. @
  398. @   Store programs into variable names.
  399. @
  400.     OBJ\-> 2 / 1 SWAP            @ Number of STO operations.
  401.     START
  402.     SWAP STO
  403.     NEXT
  404. @---------------------------------------
  405. @   Initialize some variables in the ROOT.
  406. @   Here are some place holders.  They are used so the root directory does not
  407. @   have to be resorted after extraction, feel free to delete.
  408. @
  409.     {
  410.     'PRTPAR'
  411.     { }
  412.     'IOPAR'
  413.     { }
  414.     }
  415. @
  416. @   End of list of variables.
  417. @
  418. @
  419.     OBJ\-> 2 / 1 SWAP            @ Number of STO operations.
  420.     START
  421.     SWAP STO
  422.     NEXT
  423. @---------------------------------------
  424. @
  425. @   Create these Directories in the ROOT.
  426. @
  427.     {
  428.     'EE' 'ETC' 'ECON' 'HELP' 'STATS' 'TMP'
  429.     }
  430. @
  431.     OBJ\->  1 SWAP            @ Number of STO operations.
  432.     START
  433.     CRDIR
  434.     NEXT
  435. @---------------------------------------
  436. @
  437. @   Setup User Keys.
  438. @
  439.     {
  440.     S
  441.     \<< \-> m y
  442.       \<< PATH ETC m y CALEND EVAL
  443.       \>>
  444.     \>> 13.1                @      C
  445.  
  446.     \<< DOC TMENU
  447.     \>>    14.1             @      D
  448.  
  449.     \<< PATH ETC TEA EVAL
  450.     \>>    42.1             @      T
  451.  
  452.     MKDOC  14.2             @ Gold-D
  453.     EXCO   15.1             @      E
  454.     FROMTO 16.1             @      F
  455.     GCD    21.1             @      G
  456.     IOTA   23.1             @      I
  457.     LINV   23.2             @ Gold-I
  458.     LOOP   26.1             @      L
  459.     LOP    33.1             @      O
  460.     LPP    34.1             @      P
  461.     LRED   36.1             @      R
  462.     LRNG   36.2             @ Gold-R
  463.     }
  464.                     @ Remove comment if you want keys.
  465. @   STOKEYS
  466.     DROP                @  and remove this line too.
  467. @---------------------------------------
  468. @
  469. @   Setup Flags the way I like them
  470. @
  471.     { # 8081208081050FF2h # 0h }
  472.                     @ Remove comment if you want flags.
  473. @   STOF
  474.     DROP                @  and remove this line too.
  475.  
  476. \>>
  477.  
  478.  
  479. From helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean Thu May 24 03:08:27 PDT 1990
  480. Status: RO
  481.  
  482. Article 1726 of comp.sys.handhelds:
  483. Path: helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean
  484. >From: jean@mcgill-vision.uucp (Pierre Racz)
  485. Newsgroups: comp.sys.handhelds
  486. Subject: An HP48 tool box
  487. Message-ID: <1990May23.013801.7712@larry.mcrcim.mcgill.edu>
  488. Date: 23 May 90 01:38:01 GMT
  489. Sender: root@larry.mcrcim.mcgill.edu (el Root)
  490. Reply-To: pierrer@pike.ee.mcgill.ca (Pierre Racz)
  491. Organization: Electrical Engineering McGill University
  492. Lines: 461
  493.  
  494. %%HP: T(3)A(R)F(.);
  495. @   Name      : TOOLS - Self extracting toolbox.
  496. @   Author    : Pierre Racz  &    Gregor Winslow
  497. @   Email     : pierrer <at> pike.ee.mcgill.ca
  498. @   Date      : 90-04-29
  499. @   Release   : 1.0
  500. @
  501. @   Checksum  : # 4494h
  502. @   Bytes     : 2,175.5
  503. @
  504. @   Descrip   :
  505. @        Self extracting list of functions.
  506. @        This program is designed to setup the HP48SX with global
  507. @        utilities, variables and directories.
  508. @
  509. @        Simply execute it in the directory of your choice (presumably
  510. @        the ROOT).
  511. @
  512. @        The following functions are extracted:
  513. @
  514. @        IOTA    Create a list of integers.
  515. @        LOP    Apply an operator to elements of a list.
  516. @        LPP    Apply an operator on elements of two lists in parallel.
  517. @        LRED    Reduce a list into a scalar given an operator.
  518. @        LRNG    Returns the Minimum and Maximum of a list.
  519. @        LINV    Invert a list
  520. @        LST\->    Shift a list right
  521. @        LST\<-    Shift a list left
  522. @        LCONVL    Produces a Linear Convolution of two lists.
  523. @        LOOP    Apply an operator n times.
  524. @        FROMTO    Generate n+1 numbers in given range.
  525. @        GCD    Greatest Common Divisor
  526. @        LCM    Least Common Multiple
  527. @        POLY    Create a polynomial algebraic form list of coefficients.
  528. @        BINO    Create a binomial algebraic form list of roots.
  529. @        SYND    Synthetic division of two polynomials.
  530. @        EXCO    Fully expand then fully collect.
  531. @        REVAL    Fully evaluate.
  532. @
  533. @        The following empty directories are created:
  534. @
  535. @        EE    Engineering applications
  536. @        ETC    Miscellaneous applications
  537. @        ECON    Time Value of Money
  538. @        HELP    General information storage
  539. @        STATS    Stat functions
  540. @        TMP    Temp
  541. @
  542. @        The following (dummy) variables are created.  They are
  543. @        essentially place holders for variables that the system
  544. @        automatically creates.    This preemptive creation ensures that
  545. @        the system does not change the ordering of the root directory.
  546. @
  547. @        PRTPAR    Printer parameters.
  548. @        IOPAR    IO parameters.
  549. @
  550. @        They USER Keys are defined and so are the System flags.
  551. @        A comment has to be removed to enable this feature.
  552. @
  553. @   Usage     :
  554. @        1:            No parameters required.
  555. @        TOOLS
  556. @        1:            Returns Nothing
  557. @
  558. @---------------------------------------
  559. \<<
  560.     {
  561. @
  562. @   ---
  563. @   Create a Polynomial
  564. @
  565. @   2:    'X'                             Variable
  566. @   1:    { 1 2 -3 4 }            List of Polynomial coefficients.
  567. @   POLY
  568. @   1:    'X^3+2*X^2-3*X+4'               Polynomial
  569. @
  570.     'POLY'
  571.     \<< \-> v l
  572.       \<< l SIZE \-> n
  573.     \<< 0 n 1 - 0
  574.       FOR i
  575.         l n i - GET v i ^ * +
  576.       -1 STEP
  577.     \>>
  578.       \>>
  579.     \>>
  580. @
  581. @   ---
  582. @   Synthetic Polynomial Division
  583. @
  584. @   2:    { 2 11 17 6 }            2*X^3 + 11*X^2 + 17*X + 6
  585. @   1:    { 2 1 }             divided 2*X + 1
  586. @    SYND
  587. @   2:    { 0 }                Remainder : 0
  588. @   1:    { 1 5 6 }            Quotient  : X^2 + 5*X + 6
  589. @
  590.     'SYND'
  591.     \<< \-> A B
  592.       \<< A SIZE B SIZE DUP2 - 1 + OVER 1 -
  593.     \-> n m q r
  594.     \<< 1 n
  595.       FOR i
  596.         A i GET 2 i q - 1 + MAX m
  597.         FOR j
  598.           IF j i \<=
  599.           THEN j PICK B j GET * -
  600.           END
  601.         NEXT
  602.         IF i q \<=
  603.         THEN B 1 GET /
  604.         END
  605.       NEXT
  606.       r \->LIST q 1 + ROLLD q \->LIST
  607.     \>>
  608.       \>>
  609.     \>>
  610. @
  611. @   ---
  612. @   Create a Binomial
  613. @
  614. @   2:    'X'                             Variable
  615. @   1:    { 1 2 -3 }            List of roots.
  616. @   BINO
  617. @   1:    '(X-1)*(X-2)*(X+3)'             Binomial
  618. @
  619. @
  620.     'BINO'
  621.     \<< \-> v l
  622.       \<< 1 1 l SIZE
  623.     FOR i
  624.         v l i GET - *
  625.     NEXT
  626.       \>>
  627.     \>>
  628. @
  629. @   ---
  630. @   Expand and Collect Fully
  631. @
  632. @   1:    '(X-1)*(X-2)'
  633. @   EXCO
  634. @   1:    '2+X^2-3*X'
  635. @
  636.     'EXCO'
  637.     \<<
  638.       DO DUP EXPAN SWAP
  639.       UNTIL OVER SAME
  640.       END
  641.       DO DUP COLCT SWAP
  642.       UNTIL OVER SAME
  643.       END
  644.     \>>
  645. @
  646. @   ---
  647. @   Repeated Eval (until no change)
  648. @
  649.     'REVAL'
  650.     \<<
  651.       DO DUP EVAL SWAP
  652.       UNTIL OVER SAME
  653.       END
  654.     \>>
  655. @
  656. @   ---
  657. @   Greatest Common Divisor.
  658. @
  659.     'GCD'
  660.     \<<
  661.       WHILE DUP
  662.       REPEAT SWAP OVER MOD
  663.       END DROP
  664.     \>>
  665. @
  666. @   ---
  667. @   Least Common Multiple
  668. @
  669.     'LCM'
  670.     \<< \-> a b
  671.       \<< a b * a b GCD /
  672.       \>>
  673.     \>>
  674. @
  675. @   ---
  676. @   Create a list of numbers from 0 to N
  677. @
  678. @   1:    5                n
  679. @    IOTA
  680. @   1:    { 0 1 2 3 4 5 }         Generates n+1 elements.
  681. @
  682.     'IOTA'
  683.     \<< \-> n
  684.       \<< 0 n
  685.     FOR i i
  686.     NEXT
  687.     n 1 + \->LIST
  688.       \>>
  689.     \>>
  690. @
  691. @   ---
  692. @   Invert list.
  693. @
  694. @   1:    { 0 1 2 3 4 5 }
  695. @    LINV
  696. @   1:    { 5 4 3 2 1 0 }
  697. @
  698.     'LINV'
  699.     \<< \-> L
  700.       \<< L SIZE 1
  701.     FOR i
  702.       L i GET
  703.     -1 STEP
  704.     L SIZE \->LIST
  705.       \>>
  706.     \>>
  707. @
  708. @   ---
  709. @   Rotate a list Right
  710. @
  711. @   1:    { 0 1 2 3 4 5 }
  712. @    LST\->
  713. @   1:    { 5 0 1 2 3 4 }
  714. @
  715.     'LST\->'
  716.     \<< OBJ\-> \-> SZ
  717.       \<< SZ ROLLD SZ \->LIST
  718.       \>>
  719.     \>>
  720. @
  721. @
  722. @   ---
  723. @   Rotate a list Left
  724. @
  725. @   1:    { 0 1 2 3 4 5 }
  726. @    LST\<-
  727. @   1:    { 1 2 3 4 5 0 }
  728. @
  729.     'LST\<-'
  730.     \<< OBJ\-> \-> SZ
  731.       \<< SZ ROLL SZ \->LIST
  732.       \>>
  733.     \>>
  734. @
  735. @   ---
  736. @   List OP.
  737. @
  738. @   2:    { 0 1 2 3 4 5 }
  739. @   1:    \<< 1 + \>>            Increment each element of list.
  740. @    LOP
  741. @   1:    { 1 2 3 4 5 6 }
  742. @
  743.     'LOP'
  744.     \<< \-> l f
  745.       \<< 1 l SIZE
  746.     FOR i
  747.         l i GET f EVAL
  748.     NEXT l
  749.     SIZE \->LIST
  750.       \>>
  751.     \>>
  752. @
  753. @   ---
  754. @   List Parallel Process.
  755. @
  756. @   3:    { 0 1 2 3 4 5 }
  757. @   2:    { 5 4 3 2 1 0 }
  758. @   1:    \<< * \>>            Multiply corresponding elements.
  759. @    LPP
  760. @   1:    { 0 4 6 6 4 0 }
  761. @
  762.     'LPP'
  763.     \<< \-> A B f
  764.       \<< A SIZE B SIZE MIN
  765.     \-> m
  766.     \<< 1 m
  767.       FOR i
  768.         A i GET B i GET f EVAL
  769.       NEXT m \->LIST
  770.     \>>
  771.       \>>
  772.     \>>
  773. @
  774. @   ---
  775. @   List Reduce.
  776. @
  777. @   2:    { 0 1 2 3 4 5 }
  778. @   1:    \<< + \>>            Sum the elements of the list.
  779. @    LRED
  780. @   1:    15
  781. @
  782.     'LRED'
  783.     \<< \-> L f
  784.       \<< L 1 GET 2 L SIZE
  785.     FOR i
  786.         L i GET f EVAL
  787.     NEXT
  788.       \>>
  789.     \>>
  790. @
  791. @   ---
  792. @   List range
  793. @
  794. @   1:    { 3 4 -2 1 8 }
  795. @    LRNG
  796. @   2:    -2                Minimum element of list.
  797. @   1:    8                Maximum element of list.
  798. @
  799.     'LRNG'
  800.     \<< \-> L
  801.       \<< L 1 GET DUP 2 L SIZE
  802.     FOR i L i GET
  803.       \-> m n x            @ m=min n=max x=element under test.
  804.       \<< m  x MIN n  x MAX
  805.       \>>
  806.     NEXT
  807.       \>>
  808.     \>>
  809. @
  810. @   ---
  811. @   Linear Convolution (Multiply two polynomials)
  812. @
  813. @   2:    { 1 2 1 }            X^2+2*X+1
  814. @   1:    { 1 3 3 1 }            X^3+3*X^2+3*X+1
  815. @    LCONVL
  816. @   1:    { 1 5 10 10 5 1 }        X^5 + 5*X^4 + 10*X^3 + 10*X^2 + 5*X + 1
  817. @
  818.     'LCONVL'
  819.     \<< \-> H X
  820.       \<< X SIZE H SIZE OVER + 1 - \-> N1 N    @ N Size of X
  821.     \<< 1 N                 @ N Size of result
  822.       FOR n
  823.         0 1 N1
  824.         FOR k
  825.           H n k - 1 +
  826.           IFERR GET             @ Try and get element from list.
  827.           THEN DROP2            @ Out of bounds, It is zero.
  828.           ELSE X k GET * +
  829.           END
  830.         NEXT
  831.       NEXT N \->LIST
  832.     \>>
  833.       \>>
  834.     \>>
  835. @
  836. @   ---
  837. @   Executes operation N times.
  838. @
  839. @   4:    { 1 1 }
  840. @   3:    { 1 1 }             Raise this poly to the 4th power.
  841. @   2:    \<< OVER LCONVL \>>
  842. @   1:    4
  843. @    LOOP
  844. @   2:    { 1 1 }
  845. @   1:    { 1 5 10 10 5 1 }
  846. @
  847.     'LOOP'
  848.     \<< \-> f n
  849.       \<<
  850.     WHILE 'n' DECR 0 \>=
  851.     REPEAT f EVAL
  852.     END
  853.       \>>
  854.     \>>
  855. @
  856. @   ---
  857. @   Creates List of n+1 elements from a to b.
  858. @
  859. @   3:    5                Want 5+1 elements
  860. @   2:    1                From 1
  861. @   1:    2                To   2
  862. @    FROMTO
  863. @   1:    { 1  1.2  1.4  1.6  1.8  2 }
  864. @
  865.     'FROMTO'
  866.     \<< \-> n a b
  867.       \<< n IOTA
  868.     \<< b a - n / * a +
  869.     \>> LOP
  870.       \>>
  871.     \>>
  872. @
  873.     }    @   End list of tools.
  874. @
  875. @
  876. @   Store programs into variable names.
  877. @
  878.     OBJ\-> 2 / 1 SWAP            @ Number of STO operations.
  879.     START
  880.     SWAP STO
  881.     NEXT
  882. @---------------------------------------
  883. @   Initialize some variables in the ROOT.
  884. @   Here are some place holders.  They are used so the root directory does not
  885. @   have to be resorted after extraction, feel free to delete.
  886. @
  887.     {
  888.     'PRTPAR'
  889.     { }
  890.     'IOPAR'
  891.     { }
  892.     }
  893. @
  894. @   End of list of variables.
  895. @
  896. @
  897.     OBJ\-> 2 / 1 SWAP            @ Number of STO operations.
  898.     START
  899.     SWAP STO
  900.     NEXT
  901. @---------------------------------------
  902. @
  903. @   Create these Directories in the ROOT.
  904. @
  905.     {
  906.     'EE' 'ETC' 'ECON' 'HELP' 'STATS' 'TMP'
  907.     }
  908. @
  909.     OBJ\->  1 SWAP            @ Number of STO operations.
  910.     START
  911.     CRDIR
  912.     NEXT
  913. @---------------------------------------
  914. @
  915. @   Setup User Keys.
  916. @
  917.     {
  918.     S
  919.     \<< \-> m y
  920.       \<< PATH ETC m y CALEND EVAL
  921.       \>>
  922.     \>> 13.1                @      C
  923.  
  924.     \<< DOC TMENU
  925.     \>>    14.1             @      D
  926.  
  927.     \<< PATH ETC TEA EVAL
  928.     \>>    42.1             @      T
  929.  
  930.     MKDOC  14.2             @ Gold-D
  931.     EXCO   15.1             @      E
  932.     FROMTO 16.1             @      F
  933.     GCD    21.1             @      G
  934.     IOTA   23.1             @      I
  935.     LINV   23.2             @ Gold-I
  936.     LOOP   26.1             @      L
  937.     LOP    33.1             @      O
  938.     LPP    34.1             @      P
  939.     LRED   36.1             @      R
  940.     LRNG   36.2             @ Gold-R
  941.     }
  942.                     @ Remove comment if you want keys.
  943. @   STOKEYS
  944.     DROP                @  and remove this line too.
  945. @---------------------------------------
  946. @
  947. @   Setup Flags the way I like them
  948. @
  949.     { # 8081208081050FF2h # 0h }
  950.                     @ Remove comment if you want flags.
  951. @   STOF
  952.     DROP                @  and remove this line too.
  953.  
  954. \>>
  955.  
  956.  
  957. From helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean Thu May 24 03:09:19 PDT 1990
  958. Status: RO
  959.  
  960. Article 1731 of comp.sys.handhelds:
  961. Path: helens!shelby!rutgers!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!mcgill-vision!jean
  962. >From: jean@mcgill-vision.uucp (Pierre Racz)
  963. Newsgroups: comp.sys.handhelds
  964. Subject: HP48 Tool box : Engineering Economy
  965. Message-ID: <1990May23.154022.2101@larry.mcrcim.mcgill.edu>
  966. Date: 23 May 90 15:40:22 GMT
  967. Sender: news@larry.mcrcim.mcgill.edu (Usenet File Owner)
  968. Reply-To: pierrer@pike.ee.mcgill.ca (Pierre Racz)
  969. Organization: Electrical Engineering McGill University
  970. Lines: 148
  971.  
  972. %%HP: T(3)A(R)F(.);
  973. @   Name      : ECON - Engineering Economy Tools
  974. @   Author    : Pierre Racz
  975. @   Email     : pierrer <at> pike.ee.mcgill.ca
  976. @   Date      : 90-04-29
  977. @   Release   : 1.0
  978. @
  979. @   Checksum  : # CE47h
  980. @   Bytes     : 900.0
  981. @
  982. @   Descrip   :
  983. @        This file contains a directory hierarchy for time-value-of-money
  984. @        computations.  The main directory holds the TVM functions,
  985. @        custom menu initialization and a DATA subdirectory where
  986. @        the computations should be performed.
  987. @
  988. @        The following functions have been implemented:
  989. @
  990. @        F<-P    Future given present.
  991. @        P<-A    Present given annuity.
  992. @        F<-A    Future given annuity.
  993. @        P<-G    Present given gradient.
  994. @        F<-G    Future given gradient.
  995. @        A<-G    Annuity given gradient.
  996. @        P<-C    Present given Constant rate of change.
  997. @        PRINC    Principal remaining on loan.
  998. @        EIR    Effective interest rate.
  999. @        NIR    Nominal interest rate.
  1000. @
  1001. DIR
  1002. @
  1003. @   Time Value of Money functions.
  1004. @
  1005. @
  1006.   DATA                    @ Empty directory for YOUR data.
  1007.     DIR
  1008.     END
  1009. @
  1010. @   ----
  1011. @   Custom menu
  1012. @
  1013.   CST { F\<-P P\<-A F\<-A P\<-G F\<-G A\<-G P\<-C PRINC EIR NIR }
  1014. @
  1015. @   ----
  1016. @   Future given Present.
  1017. @
  1018. @   i : Interest rate per period.
  1019. @   n : Number of periods.
  1020. @
  1021.   F\<-P
  1022.     \<< \-> i n '(1+i)^n'
  1023.     \>>
  1024. @
  1025. @   ----
  1026. @   Present given Annuity
  1027. @
  1028. @   i : Interest rate per period.
  1029. @   n : Number of periods.
  1030. @
  1031.   P\<-A
  1032.     \<< \-> i n 'F\<-A(i,n)/F\<-P(i,n)'
  1033.     \>>
  1034. @
  1035. @   ----
  1036. @   Future given Annuity
  1037. @
  1038. @   i : Interest rate per period.
  1039. @   n : Number of periods.
  1040. @
  1041.   F\<-A
  1042.     \<< \-> i n '((1+i)^n-1)/i'
  1043.     \>>
  1044. @
  1045. @   ----
  1046. @   Present given Gradient
  1047. @
  1048. @   i : Interest rate per period.
  1049. @   n : Number of periods.
  1050. @
  1051.   P\<-G
  1052.     \<< \-> i n 'P\<-A(i,
  1053. n)*A\<-G(i,n)'
  1054.     \>>
  1055. @
  1056. @   ----
  1057. @   Future given Gradient
  1058. @
  1059. @   i : Interest rate per period.
  1060. @   n : Number of periods.
  1061. @
  1062.   F\<-G
  1063.     \<< \-> i n 'F\<-A(i,n)*A\<-G(i,n)'
  1064.     \>>
  1065. @
  1066. @   ----
  1067. @   Annuity given Gradient
  1068. @
  1069. @   i : Interest rate per period.
  1070. @   n : Number of periods.
  1071. @
  1072.   A\<-G
  1073.     \<< \-> i n '1/i-n/((1+i)^n-1)'
  1074.     \>>
  1075. @
  1076. @   ----
  1077. @   Principal remaining on loan.
  1078. @
  1079. @   i : Interest rate per period.
  1080. @   n : Number of periods into loan.
  1081. @   N : Number of periods before payback of loan.
  1082. @
  1083.   PRINC
  1084.     \<< \-> i n N 'F\<-P(i,n)-P\<-C(0,i,n)/P\<-A(i,N)'
  1085.     \>>
  1086. @
  1087. @   ----
  1088. @   Effective Interest Rate.
  1089. @
  1090. @   i : Interest rate per period.
  1091. @   n : Number of periods.
  1092. @
  1093.   EIR
  1094.     \<< \-> i n '(1+i/n)^n-1'
  1095.     \>>
  1096. @
  1097. @   ----
  1098. @   Nominal Interest Rate
  1099. @
  1100. @   i : Interest rate per period.
  1101. @   n : Number of periods.
  1102. @
  1103.   NIR
  1104.     \<< \-> i n 'n*((1+i)^(1/n)-1)'
  1105.     \>>
  1106. @
  1107. @   ----
  1108. @   Present Given Changing Annuity
  1109. @
  1110. @   i : Interest rate per period.
  1111. @   k : Rate at which receipts increase.
  1112. @   n : Number of periods.
  1113. @
  1114.   P\<-C
  1115.     \<< \-> i k n '(1-((1+k)/(1+i))^n)/(i-k)'
  1116.     \>>
  1117. END
  1118. @
  1119. @
  1120.  
  1121.  
  1122.